package entities;

// Generated Aug 20, 2014 12:14:50 PM by Hibernate Tools 3.4.0.CR1

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * SanPham generated by hbm2java
 */
@Entity
@Table(name = "SanPham", catalog = "DemoHibernate")
public class SanPham implements java.io.Serializable {

	private String masanpham;
	private DanhMuc danhMuc;
	private String tensanpham;
	private int gia;
	private int soluong;
	private boolean tinhtrang;
	private String mota;
	private Date ngaysanxuat;
	private byte[] hinhanh;
	private Set<ChiTietHoaDon> chiTietHoaDons = new HashSet<ChiTietHoaDon>(0);

	public SanPham() {
	}

	public SanPham(String masanpham, DanhMuc danhMuc, String tensanpham,
			int gia, int soluong, boolean tinhtrang, String mota,
			Date ngaysanxuat, byte[] hinhanh) {
		this.masanpham = masanpham;
		this.danhMuc = danhMuc;
		this.tensanpham = tensanpham;
		this.gia = gia;
		this.soluong = soluong;
		this.tinhtrang = tinhtrang;
		this.mota = mota;
		this.ngaysanxuat = ngaysanxuat;
		this.hinhanh = hinhanh;
	}

	public SanPham(String masanpham, DanhMuc danhMuc, String tensanpham,
			int gia, int soluong, boolean tinhtrang, String mota,
			Date ngaysanxuat, byte[] hinhanh, Set<ChiTietHoaDon> chiTietHoaDons) {
		this.masanpham = masanpham;
		this.danhMuc = danhMuc;
		this.tensanpham = tensanpham;
		this.gia = gia;
		this.soluong = soluong;
		this.tinhtrang = tinhtrang;
		this.mota = mota;
		this.ngaysanxuat = ngaysanxuat;
		this.hinhanh = hinhanh;
		this.chiTietHoaDons = chiTietHoaDons;
	}

	@Id
	@Column(name = "masanpham", unique = true, nullable = false)
	public String getMasanpham() {
		return this.masanpham;
	}

	public void setMasanpham(String masanpham) {
		this.masanpham = masanpham;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "madanhmuc", nullable = false)
	public DanhMuc getDanhMuc() {
		return this.danhMuc;
	}

	public void setDanhMuc(DanhMuc danhMuc) {
		this.danhMuc = danhMuc;
	}

	@Column(name = "tensanpham", nullable = false)
	public String getTensanpham() {
		return this.tensanpham;
	}

	public void setTensanpham(String tensanpham) {
		this.tensanpham = tensanpham;
	}

	@Column(name = "gia", nullable = false)
	public int getGia() {
		return this.gia;
	}

	public void setGia(int gia) {
		this.gia = gia;
	}

	@Column(name = "soluong", nullable = false)
	public int getSoluong() {
		return this.soluong;
	}

	public void setSoluong(int soluong) {
		this.soluong = soluong;
	}

	@Column(name = "tinhtrang", nullable = false)
	public boolean isTinhtrang() {
		return this.tinhtrang;
	}

	public void setTinhtrang(boolean tinhtrang) {
		this.tinhtrang = tinhtrang;
	}

	@Column(name = "mota", nullable = false)
	public String getMota() {
		return this.mota;
	}

	public void setMota(String mota) {
		this.mota = mota;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "ngaysanxuat", nullable = false, length = 10)
	public Date getNgaysanxuat() {
		return this.ngaysanxuat;
	}

	public void setNgaysanxuat(Date ngaysanxuat) {
		this.ngaysanxuat = ngaysanxuat;
	}

	@Column(name = "hinhanh", nullable = false)
	public byte[] getHinhanh() {
		return this.hinhanh;
	}

	public void setHinhanh(byte[] hinhanh) {
		this.hinhanh = hinhanh;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "sanPham")
	public Set<ChiTietHoaDon> getChiTietHoaDons() {
		return this.chiTietHoaDons;
	}

	public void setChiTietHoaDons(Set<ChiTietHoaDon> chiTietHoaDons) {
		this.chiTietHoaDons = chiTietHoaDons;
	}

}
